function setupWebViewJavascriptBridge(callback) {
    if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
    if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
    window.WVJBCallbacks = [callback];
    var WVJBIframe = document.createElement('iframe');
    WVJBIframe.style.display = 'none';
    WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
    document.documentElement.appendChild(WVJBIframe);
    setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0);
}

// setupWebViewJavascriptBridge(function(bridge) {
//
//     document.getElementById('get').onclick = function() {
//         bridge.callHandler('network-get', {url:'http://playschool.go.c2d.me/api/test/ios/get'}, function(response) {
//             document.getElementById('text').innerText = JSON.stringify(response);
//         })
//     };
//     document.getElementById('get_cache').onclick = function() {
//         bridge.callHandler('network-get', {url:'http://playschool.go.c2d.me/api/test/ios/get',cacheKey:'88888888'}, function(response) {
//             document.getElementById('text').innerText = JSON.stringify(response);
//         })
//     };
//
//
//     document.getElementById('post').onclick = function() {
//         bridge.callHandler('network-post', {url:'http://playschool.go.c2d.me/api/test/ios/get',params:{username:'wdh',password:'123'}}, function(response) {
//             document.getElementById('text').innerText = JSON.stringify(response);
//         })
//     };
//     document.getElementById('post_cache').onclick = function() {
//         bridge.callHandler('network-post', {url:'http://playschool.go.c2d.me/api/test/ios/get',cacheKey:'88888888',params:{username:'wdh',password:'123'}}, function(response) {
//             document.getElementById('text').innerText = JSON.stringify(response);
//         })
//     };
//
//     //取消所有请求
//     document.getElementById('cancel_all_request').onclick = function() {
//         bridge.callHandler('network-operation', {operation:'cancel_all_request'}, function(response) {
//             document.getElementById('text').innerText = response;
//         })
//     };
//     //移除指定缓存
//     document.getElementById('remove_cache_key').onclick = function() {
//         bridge.callHandler('network-operation', {operation:'remove_cache_key',cacheKey:'cacheKey'}, function(response) {
//             document.getElementById('text').innerText = response;
//         })
//     };
//     //移除所有缓存
//     document.getElementById('remove_cache_all').onclick = function() {
//         bridge.callHandler('network-operation', {operation:'remove_cache_all'}, function(response) {
//             document.getElementById('text').innerText = response;
//         })
//     };
//
//     //讯飞语音
//     document.getElementById('xf_build').onclick = function() {
//         bridge.callHandler('xf-helper', {operation:'build'}, function(response) {
//             document.getElementById('text').innerText = response;
//         })
//     };
//     //供原生调用
//     bridge.registerHandler('xf-result', function(data, responseCallback) {
//         if(data.success == "true"){
//             document.getElementById('text').innerText = "匹配成功"+data.results;
//         }else{
//             document.getElementById('text').innerText = "匹配失败";
//         }
//     });
//
//     document.getElementById('xf_start').onclick = function() {
//         bridge.callHandler('xf-helper', {operation:'start'}, function(response) {
//             document.getElementById('text').innerText = "录音中。。。";
//         })
//     };
//
//     document.getElementById('xf_stop').onclick = function() {
//         bridge.callHandler('xf-helper', {operation:'stop'}, function(response) {
//             document.getElementById('text').innerText = "已停止录音";
//         })
//     };
//
//     document.getElementById('xf_dealloc').onclick = function() {
//         bridge.callHandler('xf-helper', {operation:'dealloc'}, function(response) {
//             document.getElementById('text').innerText = "释放内存成功";
//         })
//     };
//
// });
function a() {
    alert(12)
}
(function (window) {
    window.Ios = {};
    setupWebViewJavascriptBridge(function(bridge) {
        Ios = {
            //讯飞语音
            xf_build: function (buildsSuccess, resultSuccess, resultFail) {
                //供原生调用
                bridge.registerHandler('xf-result', function (data, responseCallback) {
                    if (data.success == "true") {
                        resultSuccess(data.results);
                    } else {
                        resultFail('fail');
                    }
                });
                bridge.callHandler('xf-helper', {operation: 'build'}, function (response) {
                    buildsSuccess(response);
                })
            },
            //开始录音
            xf_start: function (success) {
                bridge.callHandler('xf-helper', {operation: 'start'}, function (response) {
                    success(response);
                })
            },
            //停止录音
            xf_stop: function (success) {
                bridge.callHandler('xf-helper', {operation: 'stop'}, function (response) {
                    success(response);
                })
            },
            //释放内存
            xf_dealloc: function (success) {
                bridge.callHandler('xf-helper', {operation: 'dealloc'}, function (response) {
                    success(response);
                })
            }
        }
    });
    // if($.isEmptyObject(Ios)){
    //     alert("系统异常，获取js桥失败");
    // }
})(window);